#define LAT_DIR(a) a < 0.0 ? 'S' : 'N'
#define LON_DIR(a) a < 0.0 ? 'W' : 'E'
#define NONULL(a) a ? a : ""
+#define ISWHITESPACE(a) ((a == ' ') || (a == '\t'))
/* convert excel time (days since 1900) to time_t and back again */
#define EXCEL_TO_TIMET(a) ((a - 25569.0) * 86400.0)
size_t dlen = 0, elen = 0;
int enclosedepth = 0;
short int dfound;
+ short int hyper_whitespace_delimiter = 0;
if (tmp) {
xfree(tmp);
tmp = NULL;
}
+
+ if (strcmp(delimited_by, "\\w") == 0)
+ hyper_whitespace_delimiter = 1;
if (!p) {
/* first pass thru */
sp = p;
/* length of delimiters and enclosures */
- if (delimited_by)
+ if ((delimited_by) && (!hyper_whitespace_delimiter))
dlen = strlen(delimited_by);
if (enclosed_in)
elen = strlen(enclosed_in);
enclosedepth++;
}
- if ((!enclosedepth) && (strncmp(p, delimited_by, dlen) == 0)) {
- dfound = 1;
- } else {
- p++;
+ if (!enclosedepth) {
+ if ((dlen) && (strncmp(p, delimited_by, dlen) == 0)) {
+ dfound = 1;
+ } else if ((hyper_whitespace_delimiter) && (ISWHITESPACE(*p))) {
+ dfound = 1;
+ while (ISWHITESPACE(*p))
+ p++;
+ } else {
+ p++;
+ }
}
}
-
+
/* allocate enough space for this data field */
tmp = xcalloc((p - sp) + 1, sizeof(char));
char *shortname = NULL;
char *description = NULL;
char * anyname = NULL;
+ char * write_delimiter;
int i;
field_map_t *fmp;
queue *elem, *tmp;
+ if (strcmp(xcsv_file.field_delimiter, "\\w") == 0)
+ write_delimiter = " ";
+ else
+ write_delimiter = xcsv_file.field_delimiter;
if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
if (wpt->description) {
fmp = (field_map_t *) elem;
if (i != 0)
- fprintf (xcsv_file.xcsvfp, xcsv_file.field_delimiter);
+ fprintf (xcsv_file.xcsvfp, write_delimiter);
i++;
TAB \t
SPACE <space>
HASH #
+WHITESPACE *** SEE WHITESPACE NOTES BELOW ***
+
+WHITESPACE:
+The WHITESPACE constant has special properties. When reading data,
+WHITESPACE refers to sequential runs of SPACES and/or TABS. When
+writing data, WHITESPACE is always a single SPACE.
+
+For example, the following line:
+SOME_NAME 30.1208 -91.1365 SOME OTHER NAME
+
+Parses into the following data fields:
+SOME_NAME,30.1208,-91.1365,SOME,OTHER,NAME
+
COMMENTS:
Anything after a hash (#) on a line is not parsed. For example:
FIELD LAT_DECIMAL, "", "%f" # ONLY THIS SENTENCE IS A COMMENT.
+
GLOBAL PROPERTIES OF THE FILE:
--------------------------------
There are a few available directives to describe general traits of the